In [ ]:
# TODO Create one string, int, float and boolean variable and print them out
Most basic Python string functions are:
len(string)
string.lower()
string.upper()
str(string)
In [4]:
# TODO Check what above given functions will produce from following variables:
a = 'Some test string...'
b = 'WE ARE LEARNING...'
c = 123
In [ ]:
# TODO Concatenate all variables a, b and c into one and print it out
In [ ]:
# TODO String formatting, usefull for logging and debugging
print "The %s who %s %s!" % ("Knights", "say", "Ni")
In [ ]:
string1 = ' embedded string '
string2 = ' This is one string {}'.format(string1)
string2
In [14]:
import random
# TODO print the biggest number from the three given bellow num1, num2 and num3
num1 = random.randint(1, 100)
num2 = random.randint(1, 100)
num3 = random.randint(1, 100)
In [ ]:
# TODO if number1 is bigger, print "number1 is bigger"
# if number2 is bigger, print "number2 is bigger"
# if they are equal, print "Numbers are equal, you had 1% chance to get this..."
number1 = random.randint(1, 100)
number2 = random.randint(1, 100)
In [ ]:
# TODO if you are German and n is greater than m
# print upper case lc variable otherwise
# print lower case up variable
n = random.randint(1, 100)
m = random.randint(1, 100)
german = ? (True/False)
lc = 'lower case string'
up = 'UPPER CASE STRING'
In [15]:
# TODO remove false Beatle form the list
beatles = ["john","paul","george","ringo","stuart"]
In [ ]:
# TODO print out all the beatles with the loop
In [ ]:
# TODO make John and Ringo switch their places in the list
In [21]:
# TODO So as a reminder the Beatles are John Lennon, Paul McCartney, George Harrison and Ringo Starr
# in that respect attach proper last name to every Beatle in the list
In [ ]:
# Now just execute this...
%run man.py
From a sample of the RMS Titanic data, we can see the various features present for each passenger on the ship:
More about this data set can be found on Kaggle website.
In [2]:
# TODO import proper Python libraries to examine and investigate Titanic data set
import matplotlib.pyplot as plt
In [14]:
# TODO load Titanic training set. File name is titanic_train.csv
import pandas as pd
df = pd.read_csv('titanic_train.csv')
In [23]:
# TODO Check does any column in Titanic data set contains NaN values
In [22]:
# TODO Plot Pclass and Fare data distribution
In [ ]:
# TODO Count how many passangers are over 40 years
In [ ]:
# TODO Count how many men among passangers are over 40 years
In [ ]:
# TODO Count how many men among passangers are over 40 years survived
In [ ]:
# TODO Plot data distribution
In [ ]:
# TODO if children are considered to be under the age of 16, how many children were in Titanic
In [ ]:
# TODO How many men named Edward were among the passangers
In [ ]:
# TODO experiment yourself a bit ;-)
In [ ]:
In [ ]: